﻿$(document).ready(function () {
    $("#reroute-pannel").hide();
    $("#childCasesPart").hide();
    $("#addChildInputsWrap").hide();
    $("#jointAgencyPart").hide();
    $("#addAgencyInputsWrap").hide();
    $("#btn-reroute").click(function () {
        $("span#btn-accept-reject").toggle("fade");//toggle reject and accept button
        $("#reroute-pannel").toggle("drop");//toggle reroute pannel
        //change btn-reroute image
        var src = ($("#btn-reroute").attr('src') == 'images/btn-action-0.png')
           ? 'images/btn-action-1.png'
           : 'images/btn-action-0.png';
        $("#btn-reroute").attr('src', src);
    });
    /*-- checkboxes controls --*/
    // Add/Remove autocomplete and multi-issue input elements
    $("#checkboxes-reroute-pannel table").click(function () {
        var src = $("#reroute-pannel-image").attr('src');
        if (src == 'images/routing-panel-basic.png') {
            $("#autocompleteWrap").css('top', '45px');
            $("#autocompleteWrap").show();
            $("#addChildInputsWrap").hide();
            $("#addAgencyInputsWrap").hide();
        } else if (src == 'images/routing-panel-multi-issue.png') {
            $("#autocompleteWrap").css('top', '185px');
            $("#autocompleteWrap").show();
            $("#addChildInputsWrap").show();
            $("#addAgencyInputsWrap").hide();
        } else if (src == 'images/routing-panel-joint-resolution.png') {
            $("#autocompleteWrap").hide();
            $("#addChildInputsWrap").hide();
            $("#addAgencyInputsWrap").show();
        } else {
            $("#autocompleteWrap").hide();
            $("#addChildInputsWrap").hide();
            $("#addAgencyInputsWrap").hide();
            $("#childCasesPart").hide();
            $("#jointAgencyPart").hide();
        }

    });
    $("#cell-return").click(function () {//change reroute pannel image
        $("div#addmore img").remove();
        var src = ($("#reroute-pannel-image").attr('src') == 'images/routing-panel-return.png')
           ? 'images/routing-panel-basic.png'
           : 'images/routing-panel-return.png';
        $("#btnsend").attr('src', 'images/btn-send.png');
        $("#reroute-pannel-image").attr({ src: src, usemap: '#addChild' });
    });
    var isShowed = 0;
    $("#cell-multi").click(function () {//change reroute pannel image
        $("div#addmore img").remove();

        var src = ($("#reroute-pannel-image").attr('src') == 'images/routing-panel-multi-issue.png')
           ? 'images/routing-panel-basic.png'
           : 'images/routing-panel-multi-issue.png';
        if (src == 'images/routing-panel-multi-issue.png') {
            //$("#reroute-pannel-image").attr({ src: src, usemap: '#addChild' });
            $("#reroute-pannel-image").attr({
                src: src,
                usemap: '#addChild'
            });
            isShowed = 1;
            console.log(isShowed);
        } else {
            $("#addChildInputsWrap").hide();
            $("#reroute-pannel-image").attr({ src: src });
            isShowed = 0
            console.log(isShowed);
        }

    });
    $("#cell-joint").click(function () {//change reroute pannel image
        $("div#addmore img").remove();
        var src = ($("#reroute-pannel-image").attr('src') == 'images/routing-panel-joint-resolution.png')
           ? 'images/routing-panel-basic.png'
           : 'images/routing-panel-joint-resolution.png';
        if (src == 'images/routing-panel-joint-resolution.png') {
            //$("#reroute-pannel-image").attr({ src: src, usemap: '#addChild' });
            $("#reroute-pannel-image").attr({ src: src, usemap: '#addAgency' });
            isShowed = 1;
            console.log(isShowed);
        } else {
            $("#reroute-pannel-image").attr({ src: src });
            isShowed = 0
            console.log(isShowed);
        }


    });
    $("#cell-escalate").click(function () {//change reroute pannel image
        $("div#addmore img").remove();
        var src = ($("#reroute-pannel-image").attr('src') == 'images/routing-panel-escalate.png')
           ? 'images/routing-panel-basic.png'
           : 'images/routing-panel-escalate.png';
        $("#reroute-pannel-image").attr('src', src);
    });
});
///*---initialize DataTables-1.9.4---*/
//$("#childCaseTable").datatable();


/*-- Function to pop up alert window --*/
function SendNoti() {
    alert("Sent successfully!");
}

function ChangeBtnStyle(id, src) {
    $(id).hide().attr('src', src).show("fast");
    //$("#btnsend").hide('slow');
    //$("#btnsend").attr('src', 'images/btn-send-tick.png');
    //$("#btnsend").show('slow');
}

/*---function to add child case into the child case table---*/
function AddChildCase() {
    if (isShowed = 1) {
        $("#childCasesPart").show("slow");
        isShowed = 0;
        console.log(isShowed);
    }
    var caseID = Math.uuid(8, 16);
    var title = $("#childSubjectTitle").val();
    var curDate = moment().format('DD MMM YYYY, h:mm:ss a');
    var dueDate = moment().add('d', 3).format('DD MMM YYYY, h:mm:ss a');
    var categoty = $("#autoComp-category").text();
    var agency = $("#autoComp-agency").val();
    var newRecord = '<tr><td><a href="case-detail-child.html">' + caseID + '</a></td><td>' + title + '</td><td>' + categoty + '</td><td>Pending</td><td>' + curDate + '</td><td>' + dueDate + '</td><td>' + agency + '</td></tr>';
    //$("#childCaseTable tbody").append(newRecord);
    $(newRecord).hide().appendTo("#childCaseTable tbody").show("fast");
}

/*--- function to add agency into a table before sending ---*/
function AddAgencyToTable() {
    if (isShowed = 1) {
        $("#jointAgencyPart").show("slow");
        isShowed = 0;
        console.log(isShowed);
    }
    var agency = $("#addAgencySelector").val();
    var isLeadAgency = $("#isLeadAgency").is(":checked") ? "Yes" : "No";
    //if ($("#isLeadAgency").is(":checked")) {
    //    isLeadAgency = 'Yes';
    //} else {

    //}
    var newRecord = '<tr><td>' + agency + '</td><td>' + isLeadAgency + '</td><td>Pending</td></tr>';
    $(newRecord).hide().appendTo("#jointAgencyTable tbody").show("fast");
}


/*--function to add and remove child in Multi Issue pannel (multiple child issue can be added)--*/
var postfix = 1;
function addChildIssue() {
    var childimgid = 'addedissue' + postfix;
    var arguement = "'" + childimgid + "'";
    var element = '<img id="' + childimgid
        + '" src="images/routing-panel-multi-issue-child.png" usemap="#removeChild' + postfix
        + '"/><map name="removeChild' + postfix + '" id="removeChild' + postfix
        + '"><area alt="remove case" id="removeChildCase' + postfix
        + '" shape="rect" coords="933，0，960，25" href="javascript:removeChildIssue(' + arguement
        + ')"/><area alt="add case" id="addChildCase' + postfix
        + '" shape="rect" coords="825，0，929，25" href="javascript:addChildIssue()"/></map>'
    $(element).hide().appendTo("div#addmore").show("drop", { direction: "down" });
    postfix++;
}
function removeChildIssue(removeid) {
    $('div#addmore img#' + removeid).hide("drop", { direction: "down" }, function () {
        $(this).remove();
    });
}

/*--function to add and remove agency in Joint Resolution pannel--*/
var lastNum = 1;
function AddAgency() {
    var childimgid = 'addedagency' + lastNum;
    var arguement = "'" + childimgid + "'";
    var element = '<img id="' + childimgid
        + '" src="images/routing-panel-joint-resolution-agency.png" usemap="#removeAgency' + lastNum
        + '"/><map name="removeAgency' + lastNum + '" id="removeAgency' + lastNum
        + '"><area alt="remove agency" id="removeChildCase' + lastNum
        + '" shape="rect" coords="932,0,960,25" href="javascript:removeAgency(' + arguement
        + ')" /><area alt="add agency" id="addChildCase' + lastNum
        + '" shape="rect" coords="834,0,928,25" href="javascript:addAgency()" /></map>'
    $(element).hide().appendTo("div#addmore").show("drop", { direction: "down" });
    lastNum++;
}
function removeAgency(removeid) {
    $('div#addmore img#' + removeid).hide("drop", { direction: "down" }, function () {
        $(this).remove();
    });
}



/*---Autocomplete widget---*/
var availableTags =
        [{ label: "accident", category: "Traffic Safety", subCategory: "", agency: "LTA" },
        { label: "air", category: "Air Pollution", subCategory: "", agency: "NEA" },
        { label: "Air Pollution", category: "Air Pollution", subCategory: "", agency: "NEA" },
        { label: "Animal", category: "Animal", subCategory: "Birds", agency: "NEA" },
        { label: "Animal", category: "Animal", subCategory: "Defecating/Urinating", agency: "NEA" },
        { label: "Animal", category: "Animal", subCategory: "", agency: "AVA" },
        { label: "animal dropping", category: "Animal", subCategory: "Birds", agency: "NEA" },
        { label: "animal dropping", category: "Animal", subCategory: "Defecating/Urinating", agency: "NEA" },
        { label: "animal dropping", category: "Animal", subCategory: "", agency: "AVA" },
        { label: "appeal", category: "Appeals & Fines", subCategory: "Vehicle Offences", agency: "LTA" },
        { label: "appeal", category: "Appeals & Fines", subCategory: "Smoky Vehicle", agency: "NEA" },
        { label: "appeal", category: "Appeals & Fines", subCategory: "Littering", agency: "NEA" },
        { label: "Appeals & Fines", category: "Appeals & Fines", subCategory: "Vehicle Offences", agency: "LTA" },
        { label: "Appeals & Fines", category: "Appeals & Fines", subCategory: "Smoky Vehicle", agency: "NEA" },
        { label: "Appeals & Fines", category: "Appeals & Fines", subCategory: "Littering", agency: "NEA" },
        { label: "application", category: "Licensing", subCategory: "Vehicle Related", agency: "LTA" },
        { label: "application", category: "Licensing", subCategory: "", agency: "NEA" },
        { label: "BCA", category: "Fire Hazard", subCategory: "", agency: "HDB" },
        { label: "bicycle", category: "Bicycle Cover", subCategory: "Car Parks", agency: "HDB" },
        { label: "bicycle", category: "Bicycle Cover", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "Bicycle Cover", category: "Bicycle Cover", subCategory: "Car Parks", agency: "HDB" },
        { label: "Bicycle Cover", category: "Bicycle Cover", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "bicycle lamp", category: "Bicycle Cover", subCategory: "Car Parks", agency: "HDB" },
        { label: "bicycle lamp", category: "Bicycle Cover", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "bike", category: "Vehicle", subCategory: "", agency: "LTA" },
        { label: "bike", category: "Vehicle", subCategory: "Idling Engine & Smoky", agency: "NEA" },
        { label: "bin", category: "Waste Collection", subCategory: "", agency: "NEA" },
        { label: "bird", category: "Animal", subCategory: "Birds", agency: "NEA" },
        { label: "bird", category: "Animal", subCategory: "Defecating/Urinating", agency: "NEA" },
        { label: "bird", category: "Animal", subCategory: "", agency: "AVA" },
        { label: "bird feeding", category: "Animal", subCategory: "Birds", agency: "NEA" },
        { label: "bird feeding", category: "Animal", subCategory: "Defecating/Urinating", agency: "NEA" },
        { label: "bird feeding", category: "Animal", subCategory: "", agency: "AVA" },
        { label: "Birds", category: "Animal", subCategory: "Birds", agency: "NEA" },
        { label: "branch overgrown", category: "Tree & Plant Pruning", subCategory: "", agency: "NPARKS" },
        { label: "breeding", category: "Mosquito", subCategory: "", agency: "NEA" },
        { label: "build bridges", category: "Elderly Facilities", subCategory: "", agency: "HDB" },
        { label: "burning smell", category: "Air Pollution", subCategory: "", agency: "NEA" },
        { label: "bus stop", category: "Public Transport", subCategory: "", agency: "LTA" },
        { label: "buses", category: "Public Transport", subCategory: "", agency: "LTA" },
        { label: "Car Parks", category: "Bicycle Cover", subCategory: "Car Parks", agency: "HDB" },
        { label: "Car Parks", category: "Residential Matters", subCategory: "Car Parks", agency: "HDB" },
        { label: "Car Parks", category: "Pedestrian Walkway", subCategory: "Car Parks", agency: "HDB" },
        { label: "Car Parks Issues", category: "Car Parks Issues", subCategory: "", agency: "HDB" },
        { label: "card", category: "ERP Gantry", subCategory: "", agency: "LTA" },
        { label: "carpark space", category: "Car Parks Issues", subCategory: "", agency: "HDB" },
        { label: "cat", category: "Animal", subCategory: "Birds", agency: "NEA" },
        { label: "cat", category: "Animal", subCategory: "Defecating/Urinating", agency: "NEA" },
        { label: "cat", category: "Animal", subCategory: "", agency: "AVA" },
        { label: "choked drain", category: "Choked Drain", subCategory: "Cleanliness", agency: "NEA" },
        { label: "choked drain", category: "Choked Drain", subCategory: "Vectors ", agency: "NEA" },
        { label: "choked drain", category: "Choked Drain", subCategory: "", agency: "PUB" },
        { label: "Cleanliness", category: "Choked Drain", subCategory: "Cleanliness", agency: "NEA" },
        { label: "Cleanliness & Littering", category: "Residential Matters", subCategory: "Cleanliness & Littering", agency: "NEA" },
        { label: "commute\n", category: "Public Transport", subCategory: "", agency: "LTA" },
        { label: "congestion", category: "Traffic Congestion", subCategory: "", agency: "LTA" },
        { label: "Construction Noise", category: "Construction Noise", subCategory: "Renovation", agency: "HDB" },
        { label: "Construction Noise", category: "Construction Noise", subCategory: "", agency: "NEA" },
        { label: "construction site", category: "Construction Noise", subCategory: "Renovation", agency: "HDB" },
        { label: "construction site", category: "Construction Noise", subCategory: "", agency: "NEA" },
        { label: "contractor", category: "Renovation Issues", subCategory: "Dust & Noise", agency: "NEA" },
        { label: "contractor", category: "Renovation Issues", subCategory: "", agency: "HDB" },
        { label: "cooking", category: "Market & Hawker Centre", subCategory: "", agency: "NEA" },
        { label: "corridor", category: "Smoking", subCategory: "", agency: "NEA" },
        { label: "cover", category: "Bicycle Cover", subCategory: "Car Parks", agency: "HDB" },
        { label: "cover", category: "Bicycle Cover", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "crossing", category: "Traffic Safety", subCategory: "", agency: "LTA" },
        { label: "cycle", category: "Bicycle Cover", subCategory: "Car Parks", agency: "HDB" },
        { label: "cycle", category: "Bicycle Cover", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "danger", category: "Traffic Safety", subCategory: "", agency: "LTA" },
        { label: "day biter", category: "Mosquito", subCategory: "", agency: "NEA" },
        { label: "debris", category: "Renovation Issues", subCategory: "Dust & Noise", agency: "NEA" },
        { label: "debris", category: "Renovation Issues", subCategory: "", agency: "HDB" },
        { label: "Defecating/Urinating", category: "Animal", subCategory: "Defecating/Urinating", agency: "NEA" },
        { label: "Dirty toilet premise", category: "Toilet Cleanliness", subCategory: "", agency: "NEA" },
        { label: "disposal", category: "Waste Collection", subCategory: "", agency: "NEA" },
        { label: "dog", category: "Animal", subCategory: "Birds", agency: "NEA" },
        { label: "dog", category: "Animal", subCategory: "Defecating/Urinating", agency: "NEA" },
        { label: "dog", category: "Animal", subCategory: "", agency: "AVA" },
        { label: "drainage", category: "Choked Drain", subCategory: "Cleanliness", agency: "NEA" },
        { label: "drainage", category: "Choked Drain", subCategory: "Vectors ", agency: "NEA" },
        { label: "drainage", category: "Choked Drain", subCategory: "", agency: "PUB" },
        { label: "drill", category: "Construction Noise", subCategory: "Renovation", agency: "HDB" },
        { label: "drill", category: "Construction Noise", subCategory: "", agency: "NEA" },
        { label: "Dust & Noise", category: "Renovation Issues", subCategory: "Dust & Noise", agency: "NEA" },
        { label: "elderly", category: "Elderly Facilities", subCategory: "", agency: "HDB" },
        { label: "Elderly Facilities", category: "Elderly Facilities", subCategory: "", agency: "HDB" },
        { label: "electricity", category: "Street Light", subCategory: "", agency: "LTA" },
        { label: "enforcement", category: "Illegal Parking", subCategory: "HDB Premise", agency: "HDB" },
        { label: "enforcement", category: "Illegal Parking", subCategory: "", agency: "LTA" },
        { label: "engine", category: "Vehicle", subCategory: "", agency: "LTA" },
        { label: "engine", category: "Vehicle", subCategory: "Idling Engine & Smoky", agency: "NEA" },
        { label: "enquire", category: "General Enquiries", subCategory: "Information", agency: "NEA" },
        { label: "enquire", category: "General Enquiries", subCategory: "PUB-One", agency: "PUB" },
        { label: "enquiry", category: "General Enquiries", subCategory: "Information", agency: "NEA" },
        { label: "enquiry", category: "General Enquiries", subCategory: "PUB-One", agency: "PUB" },
        { label: "enter PIE", category: "ERP Gantry", subCategory: "", agency: "LTA" },
        { label: "ERP", category: "ERP Gantry", subCategory: "", agency: "LTA" },
        { label: "ERP Gantry", category: "ERP Gantry", subCategory: "", agency: "LTA" },
        { label: "estate management", category: "Residential Matters", subCategory: "Car Parks", agency: "HDB" },
        { label: "estate management", category: "Residential Matters", subCategory: "Cleanliness & Littering", agency: "NEA" },
        { label: "exhaust", category: "Air Pollution", subCategory: "", agency: "NEA" },
        { label: "exit", category: "ERP Gantry", subCategory: "", agency: "LTA" },
        { label: "expiry", category: "Tax Renewal", subCategory: "Road Tax", agency: "LTA" },
        { label: "expiry", category: "Tax Renewal", subCategory: "Market & Hawker Centre", agency: "NEA" },
        { label: "expiry", category: "Tax Renewal", subCategory: "SPServices", agency: "PUB" },
        { label: "fallen tree", category: "Tree & Plant Pruning", subCategory: "", agency: "NPARKS" },
        { label: "FCR", category: "General Enquiries", subCategory: "Information", agency: "NEA" },
        { label: "FCR", category: "General Enquiries", subCategory: "PUB-One", agency: "PUB" },
        { label: "fine", category: "Appeals & Fines", subCategory: "Vehicle Offences", agency: "LTA" },
        { label: "fine", category: "Appeals & Fines", subCategory: "Smoky Vehicle", agency: "NEA" },
        { label: "fine", category: "Appeals & Fines", subCategory: "Littering", agency: "NEA" },
        { label: "fire engine", category: "Fire Hazard", subCategory: "", agency: "HDB" },
        { label: "fire hazard", category: "Fire Hazard", subCategory: "", agency: "HDB" },
        { label: "food stall", category: "Market & Hawker Centre", subCategory: "", agency: "NEA" },
        { label: "foodshop licence", category: "Licensing", subCategory: "Vehicle Related", agency: "LTA" },
        { label: "foodshop licence", category: "Licensing", subCategory: "", agency: "NEA" },
        { label: "footpath", category: "Bicycle Cover", subCategory: "Car Parks", agency: "HDB" },
        { label: "footpath", category: "Bicycle Cover", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "Gantry", category: "ERP Gantry", subCategory: "", agency: "LTA" },
        { label: "General Enquiries", category: "General Enquiries", subCategory: "Information", agency: "NEA" },
        { label: "General Enquiries", category: "General Enquiries", subCategory: "PUB-One", agency: "PUB" },
        { label: "grass cut", category: "Grass Cutting", subCategory: "Grass Cutting", agency: "NPARKS" },
        { label: "Grass Cutting", category: "Grass Cutting", subCategory: "Grass Cutting", agency: "NPARKS" },
        { label: "hawker centre", category: "Market & Hawker Centre", subCategory: "", agency: "NEA" },
        { label: "hawking", category: "Market & Hawker Centre", subCategory: "", agency: "NEA" },
        { label: "HDB Premise", category: "Illegal Parking", subCategory: "HDB Premise", agency: "HDB" },
        { label: "high-rise littering", category: "Littering", subCategory: "HDB Premise", agency: "HDB" },
        { label: "high-rise littering", category: "Littering", subCategory: "", agency: "NEA" },
        { label: "hospital upgrade", category: "Elderly Facilities", subCategory: "", agency: "HDB" },
        { label: "house dust", category: "Renovation Issues", subCategory: "Dust & Noise", agency: "NEA" },
        { label: "house dust", category: "Renovation Issues", subCategory: "", agency: "HDB" },
        { label: "hygiene", category: "Market & Hawker Centre", subCategory: "", agency: "NEA" },
        { label: "Idling Engine & Smoky", category: "Vehicle", subCategory: "Idling Engine & Smoky", agency: "NEA" },
        { label: "illegal", category: "Illegal Parking", subCategory: "HDB Premise", agency: "HDB" },
        { label: "illegal", category: "Illegal Parking", subCategory: "", agency: "LTA" },
        { label: "Illegal Parking", category: "Illegal Parking", subCategory: "HDB Premise", agency: "HDB" },
        { label: "Illegal Parking", category: "Illegal Parking", subCategory: "", agency: "LTA" },
        { label: "immediate action", category: "Police", subCategory: "Vehicle & Illegal Parking", agency: "LTA" },
        { label: "immediate action", category: "Police", subCategory: "", agency: "SPF" },
        { label: "Information", category: "General Enquiries", subCategory: "Information", agency: "NEA" },
        { label: "installation of lift", category: "Elderly Facilities", subCategory: "", agency: "HDB" },
        { label: "jam", category: "Traffic Congestion", subCategory: "", agency: "LTA" },
        { label: "junction", category: "Traffic Congestion", subCategory: "", agency: "LTA" },
        { label: "lamp", category: "Street Light", subCategory: "", agency: "LTA" },
        { label: "lane", category: "Traffic Congestion", subCategory: "", agency: "LTA" },
        { label: "late service fee", category: "Tax Renewal", subCategory: "Road Tax", agency: "LTA" },
        { label: "late service fee", category: "Tax Renewal", subCategory: "Market & Hawker Centre", agency: "NEA" },
        { label: "late service fee", category: "Tax Renewal", subCategory: "SPServices", agency: "PUB" },
        { label: "leak", category: "Water Pipe Leaking", subCategory: "", agency: "PUB" },
        { label: "letter", category: "Appeals & Fines", subCategory: "Vehicle Offences", agency: "LTA" },
        { label: "letter", category: "Appeals & Fines", subCategory: "Smoky Vehicle", agency: "NEA" },
        { label: "letter", category: "Appeals & Fines", subCategory: "Littering", agency: "NEA" },
        { label: "license", category: "Licensing", subCategory: "Vehicle Related", agency: "LTA" },
        { label: "license", category: "Licensing", subCategory: "", agency: "NEA" },
        { label: "Licensing", category: "Licensing", subCategory: "Vehicle Related", agency: "LTA" },
        { label: "Licensing", category: "Licensing", subCategory: "", agency: "NEA" },
        { label: "light", category: "Street Light", subCategory: "", agency: "LTA" },
        { label: "litter", category: "Littering", subCategory: "HDB Premise", agency: "HDB" },
        { label: "litter", category: "Littering", subCategory: "", agency: "NEA" },
        { label: "Littering", category: "Littering", subCategory: "HDB Premise", agency: "HDB" },
        { label: "Littering", category: "Littering", subCategory: "", agency: "NEA" },
        { label: "Littering", category: "Appeals & Fines", subCategory: "Littering", agency: "NEA" },
        { label: "loud", category: "Construction Noise", subCategory: "Renovation", agency: "HDB" },
        { label: "loud", category: "Construction Noise", subCategory: "", agency: "NEA" },
        { label: "machinery\n", category: "Construction Noise", subCategory: "Renovation", agency: "HDB" },
        { label: "machinery\n", category: "Construction Noise", subCategory: "", agency: "NEA" },
        { label: "manhole", category: "Sewer", subCategory: "Traffic Related", agency: "LTA" },
        { label: "manhole", category: "Sewer", subCategory: "Weather Related", agency: "NEA" },
        { label: "manhole", category: "Sewer", subCategory: "Chokage", agency: "PUB" },
        { label: "market", category: "Market & Hawker Centre", subCategory: "", agency: "NEA" },
        { label: "Market & Hawker Centre", category: "Market & Hawker Centre", subCategory: "", agency: "NEA" },
        { label: "Market & Hawker Centre", category: "Tax Renewal", subCategory: "Market & Hawker Centre", agency: "NEA" },
        { label: "meter", category: "Water Pipe Leaking", subCategory: "", agency: "PUB" },
        { label: "monkey", category: "Animal", subCategory: "Birds", agency: "NEA" },
        { label: "monkey", category: "Animal", subCategory: "Defecating/Urinating", agency: "NEA" },
        { label: "monkey", category: "Animal", subCategory: "", agency: "AVA" },
        { label: "mosquito", category: "Mosquito", subCategory: "", agency: "NEA" },
        { label: "motor payment", category: "Tax Renewal", subCategory: "Road Tax", agency: "LTA" },
        { label: "motor payment", category: "Tax Renewal", subCategory: "Market & Hawker Centre", agency: "NEA" },
        { label: "motor payment", category: "Tax Renewal", subCategory: "SPServices", agency: "PUB" },
        { label: "mrt station", category: "Public Transport", subCategory: "", agency: "LTA" },
        { label: "night biter\n", category: "Mosquito", subCategory: "", agency: "NEA" },
        { label: "noise", category: "Construction Noise", subCategory: "Renovation", agency: "HDB" },
        { label: "noise", category: "Construction Noise", subCategory: "", agency: "NEA" },
        { label: "noise pollution", category: "Construction Noise", subCategory: "Renovation", agency: "HDB" },
        { label: "noise pollution", category: "Construction Noise", subCategory: "", agency: "NEA" },
        { label: "noisy", category: "Construction Noise", subCategory: "Renovation", agency: "HDB" },
        { label: "noisy", category: "Construction Noise", subCategory: "", agency: "NEA" },
        { label: "notice", category: "Appeals & Fines", subCategory: "Vehicle Offences", agency: "LTA" },
        { label: "notice", category: "Appeals & Fines", subCategory: "Smoky Vehicle", agency: "NEA" },
        { label: "notice", category: "Appeals & Fines", subCategory: "Littering", agency: "NEA" },
        { label: "obstruct", category: "Pedestrian Walkway", subCategory: "Car Parks", agency: "HDB" },
        { label: "obstruct", category: "Pedestrian Walkway", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "offence", category: "Appeals & Fines", subCategory: "Vehicle Offences", agency: "LTA" },
        { label: "offence", category: "Appeals & Fines", subCategory: "Smoky Vehicle", agency: "NEA" },
        { label: "offence", category: "Appeals & Fines", subCategory: "Littering", agency: "NEA" },
        { label: "overhead bridges", category: "Elderly Facilities", subCategory: "", agency: "HDB" },
        { label: "parking", category: "Illegal Parking", subCategory: "HDB Premise", agency: "HDB" },
        { label: "parking", category: "Illegal Parking", subCategory: "", agency: "LTA" },
        { label: "parking violation", category: "Illegal Parking", subCategory: "HDB Premise", agency: "HDB" },
        { label: "parking violation", category: "Illegal Parking", subCategory: "", agency: "LTA" },
        { label: "Pass", category: "ERP Gantry", subCategory: "", agency: "LTA" },
        { label: "passenger complaint", category: "Taxi Matters", subCategory: "", agency: "LTA" },
        { label: "pavement", category: "Pedestrian Walkway", subCategory: "Car Parks", agency: "HDB" },
        { label: "pavement", category: "Pedestrian Walkway", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "peak hour\n", category: "Traffic Congestion", subCategory: "", agency: "LTA" },
        { label: "pedestrian", category: "Pedestrian Walkway", subCategory: "Car Parks", agency: "HDB" },
        { label: "pedestrian", category: "Pedestrian Walkway", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "pedestrian safety", category: "Traffic Safety", subCategory: "", agency: "LTA" },
        { label: "Pedestrian Walkway", category: "Pedestrian Walkway", subCategory: "Car Parks", agency: "HDB" },
        { label: "Pedestrian Walkway", category: "Pedestrian Walkway", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "people smoking", category: "Smoking", subCategory: "", agency: "NEA" },
        { label: "pigeon", category: "Animal", subCategory: "Birds", agency: "NEA" },
        { label: "pigeon", category: "Animal", subCategory: "Defecating/Urinating", agency: "NEA" },
        { label: "pigeon", category: "Animal", subCategory: "", agency: "AVA" },
        { label: "pipe", category: "Water Pipe Leaking", subCategory: "", agency: "PUB" },
        { label: "plant removal", category: "Tree & Plant Pruning", subCategory: "", agency: "NPARKS" },
        { label: "Police", category: "Police", subCategory: "Vehicle & Illegal Parking", agency: "LTA" },
        { label: "Police", category: "Police", subCategory: "", agency: "SPF" },
        { label: "police force", category: "Police", subCategory: "Vehicle & Illegal Parking", agency: "LTA" },
        { label: "police force", category: "Police", subCategory: "", agency: "SPF" },
        { label: "pollute", category: "Air Pollution", subCategory: "", agency: "NEA" },
        { label: "pruning\n", category: "Tree & Plant Pruning", subCategory: "", agency: "NPARKS" },
        { label: "Public Transport", category: "Public Transport", subCategory: "", agency: "LTA" },
        { label: "PUB-One", category: "General Enquiries", subCategory: "PUB-One", agency: "PUB" },
        { label: "recycle refuse", category: "Waste Collection", subCategory: "", agency: "NEA" },
        { label: "registration card", category: "Vehicle", subCategory: "", agency: "LTA" },
        { label: "registration card", category: "Vehicle", subCategory: "Idling Engine & Smoky", agency: "NEA" },
        { label: "renew tax", category: "Tax Renewal", subCategory: "Road Tax", agency: "LTA" },
        { label: "renew tax", category: "Tax Renewal", subCategory: "Market & Hawker Centre", agency: "NEA" },
        { label: "renew tax", category: "Tax Renewal", subCategory: "SPServices", agency: "PUB" },
        { label: "renovation", category: "Renovation Issues", subCategory: "Dust & Noise", agency: "NEA" },
        { label: "renovation", category: "Renovation Issues", subCategory: "", agency: "HDB" },
        { label: "Renovation", category: "Construction Noise", subCategory: "Renovation", agency: "HDB" },
        { label: "Renovation Issues", category: "Renovation Issues", subCategory: "Dust & Noise", agency: "NEA" },
        { label: "Renovation Issues", category: "Renovation Issues", subCategory: "", agency: "HDB" },
        { label: "residential issues and matters", category: "Residential Matters", subCategory: "Car Parks", agency: "HDB" },
        { label: "residential issues and matters", category: "Residential Matters", subCategory: "Cleanliness & Littering", agency: "NEA" },
        { label: "Residential Matters", category: "Residential Matters", subCategory: "Car Parks", agency: "HDB" },
        { label: "Residential Matters", category: "Residential Matters", subCategory: "Cleanliness & Littering", agency: "NEA" },
        { label: "Road Infrastructure", category: "Bicycle Cover", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "Road Infrastructure", category: "Pedestrian Walkway", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "Road Tax", category: "Tax Renewal", subCategory: "Road Tax", agency: "LTA" },
        { label: "rubbish collection", category: "Waste Collection", subCategory: "", agency: "NEA" },
        { label: "sale", category: "General Enquiries", subCategory: "Information", agency: "NEA" },
        { label: "sale", category: "General Enquiries", subCategory: "PUB-One", agency: "PUB" },
        { label: "sbs", category: "Public Transport", subCategory: "", agency: "LTA" },
        { label: "school", category: "Fire Hazard", subCategory: "", agency: "HDB" },
        { label: "season parking", category: "Car Parks Issues", subCategory: "", agency: "HDB" },
        { label: "sewer", category: "Sewer", subCategory: "Traffic Related", agency: "LTA" },
        { label: "sewer", category: "Sewer", subCategory: "Weather Related", agency: "NEA" },
        { label: "sewer", category: "Sewer", subCategory: "Chokage", agency: "PUB" },
        { label: "smoke", category: "Smoking", subCategory: "", agency: "NEA" },
        { label: "Smoking", category: "Smoking", subCategory: "", agency: "NEA" },
        { label: "Smoky Vehicle", category: "Appeals & Fines", subCategory: "Smoky Vehicle", agency: "NEA" },
        { label: "smrt service", category: "Public Transport", subCategory: "", agency: "LTA" },
        { label: "speeding", category: "Traffic Safety", subCategory: "", agency: "LTA" },
        { label: "SPF", category: "Police", subCategory: "Vehicle & Illegal Parking", agency: "LTA" },
        { label: "SPF", category: "Police", subCategory: "", agency: "SPF" },
        { label: "SPServices", category: "Tax Renewal", subCategory: "SPServices", agency: "PUB" },
        { label: "status applying", category: "Licensing", subCategory: "Vehicle Related", agency: "LTA" },
        { label: "status applying", category: "Licensing", subCategory: "", agency: "NEA" },
        { label: "Street Light", category: "Street Light", subCategory: "", agency: "LTA" },
        { label: "street post", category: "Street Light", subCategory: "", agency: "LTA" },
        { label: "submit letter", category: "Licensing", subCategory: "Vehicle Related", agency: "LTA" },
        { label: "submit letter", category: "Licensing", subCategory: "", agency: "NEA" },
        { label: "summon", category: "Appeals & Fines", subCategory: "Vehicle Offences", agency: "LTA" },
        { label: "summon", category: "Appeals & Fines", subCategory: "Smoky Vehicle", agency: "NEA" },
        { label: "summon", category: "Appeals & Fines", subCategory: "Littering", agency: "NEA" },
        { label: "supermarket", category: "General Enquiries", subCategory: "Information", agency: "NEA" },
        { label: "supermarket", category: "General Enquiries", subCategory: "PUB-One", agency: "PUB" },
        { label: "Tax Renewal", category: "Tax Renewal", subCategory: "Road Tax", agency: "LTA" },
        { label: "Tax Renewal", category: "Tax Renewal", subCategory: "Market & Hawker Centre", agency: "NEA" },
        { label: "Tax Renewal", category: "Tax Renewal", subCategory: "SPServices", agency: "PUB" },
        { label: "taxi driver", category: "Taxi Matters", subCategory: "", agency: "LTA" },
        { label: "Taxi Matters", category: "Taxi Matters", subCategory: "", agency: "LTA" },
        { label: "taxi stand", category: "Taxi Matters", subCategory: "", agency: "LTA" },
        { label: "throwing cigarette butt \n", category: "Littering", subCategory: "HDB Premise", agency: "HDB" },
        { label: "throwing cigarette butt \n", category: "Littering", subCategory: "", agency: "NEA" },
        { label: "Toilet Cleanliness", category: "Toilet Cleanliness", subCategory: "", agency: "NEA" },
        { label: "traffic", category: "Traffic Congestion", subCategory: "", agency: "LTA" },
        { label: "traffic", category: "Traffic Safety", subCategory: "", agency: "LTA" },
        { label: "Traffic Congestion", category: "Traffic Congestion", subCategory: "", agency: "LTA" },
        { label: "Traffic Safety", category: "Traffic Safety", subCategory: "", agency: "LTA" },
        { label: "train", category: "Public Transport", subCategory: "", agency: "LTA" },
        { label: "Tree & Plant Pruning", category: "Tree & Plant Pruning", subCategory: "", agency: "NPARKS" },
        { label: "Vectors ", category: "Choked Drain", subCategory: "Vectors ", agency: "NEA" },
        { label: "vehicle", category: "Illegal Parking", subCategory: "HDB Premise", agency: "HDB" },
        { label: "vehicle", category: "Illegal Parking", subCategory: "", agency: "LTA" },
        { label: "vehicle", category: "Tax Renewal", subCategory: "Road Tax", agency: "LTA" },
        { label: "vehicle", category: "Tax Renewal", subCategory: "Market & Hawker Centre", agency: "NEA" },
        { label: "vehicle", category: "Tax Renewal", subCategory: "SPServices", agency: "PUB" },
        { label: "vehicle", category: "Vehicle", subCategory: "", agency: "LTA" },
        { label: "vehicle", category: "Vehicle", subCategory: "Idling Engine & Smoky", agency: "NEA" },
        { label: "Vehicle Offences", category: "Appeals & Fines", subCategory: "Vehicle Offences", agency: "LTA" },
        { label: "Vehicle Related", category: "Licensing", subCategory: "Vehicle Related", agency: "LTA" },
        { label: "void deck", category: "Smoking", subCategory: "", agency: "NEA" },
        { label: "walkway", category: "Pedestrian Walkway", subCategory: "Car Parks", agency: "HDB" },
        { label: "walkway", category: "Pedestrian Walkway", subCategory: "Road Infrastructure", agency: "LTA" },
        { label: "waste", category: "Waste Collection", subCategory: "", agency: "NEA" },
        { label: "Waste Collection", category: "Waste Collection", subCategory: "", agency: "NEA" },
        { label: "water", category: "Water Pipe Leaking", subCategory: "", agency: "PUB" },
        { label: "water drain", category: "Choked Drain", subCategory: "Cleanliness", agency: "NEA" },
        { label: "water drain", category: "Choked Drain", subCategory: "Vectors ", agency: "NEA" },
        { label: "water drain", category: "Choked Drain", subCategory: "", agency: "PUB" },
        { label: "Water Pipe Leaking", category: "Water Pipe Leaking", subCategory: "", agency: "PUB" },
        { label: "water pressure\n", category: "Water Pipe Leaking", subCategory: "", agency: "PUB" },
        { label: "weather", category: "General Enquiries", subCategory: "Information", agency: "NEA" },
        { label: "weather", category: "General Enquiries", subCategory: "PUB-One", agency: "PUB" },
        { label: "weekend visitor", category: "Car Parks Issues", subCategory: "", agency: "HDB" }];

$(document).ready(function () {
    $("#autoComp").autocomplete({
        minLength: 1,
        source: availableTags,
        focus: function (event, ui) {
            $("#autoComp").val(ui.item.label);
            $("#autoComp-category").html(ui.item.category);
            $("#autoComp-agency").val(ui.item.agency);
            $("#autoComp-subCate").html(ui.item.subCategory);
            return false;
        },
        select: function (event, ui) {
            $("#autoComp-category").html(ui.item.category);
            $("#autoComp-agency").val(ui.item.agency);
            $("#autoComp-subCate").html(ui.item.subCategory);
            return false;
        }
    }).data("ui-autocomplete")._renderItem = function (ul, item) {
        return $('<li>')
          .append('<a>' + item.label + '<br/><span style="font-size:12px;font-style:italic;">' + item.category + "  " + item.subCategory + "</span></a>")
          .appendTo(ul);
    };
});